import { Subscription } from 'rxjs/Subscription';

import { Component, Input } from '@angular/core';

@Component({
  selector: 'ngx-busy',
  templateUrl: './ngx-busy.html'
})

export class BusyComponent {

  @Input() busy: Subscription;

  constructor() { }

  shownSpinner() {
    return this.isSubscriptionDefined() && this.isSubscriptionOpen();
  }


  isSubscriptionOpen() {
    return this.busy.closed === false;
  }


  isSubscriptionDefined() {
    return typeof this.busy !== 'undefined';
  }
}

